<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button>停</button>
    <script>
      var time2 = setTimeout(function () {
        console.log('五秒后爆炸')
      }, 5000)
      var time1 = setInterval(function () {
        console.log('1秒后爆炸')
      }, 1000)
      //   停止计时器
      var btn = document.querySelector('button')
      btn.onclick = function () {
        clearTimeout(time1)
        clearTimeout(time2)
      }
    </script>
  </body>
</html>
